package icu.lookyousmileface.deadlock;

import java.util.concurrent.TimeUnit;

/**
 * @author starrysky
 * @title: MyDeadThread
 * @projectName Juc_Pro
 * @description: 线程类
 * @date 2021/1/309:51 下午
 */
public class MyDeadThread implements Runnable{

    private  String lockA;
    private  String lockB;

    public MyDeadThread(String lockA, String lockB) {
        this.lockA = lockA;
        this.lockB = lockB;
    }

    @Override
    public void run() {
        synchronized (lockA){
            System.out.println(Thread.currentThread().getName()+"=>lockA");
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (lockB){
                System.out.println(Thread.currentThread().getName()+"=>lockB");
            }
        }
    }
}
